<?php
	include "../../public/commom/config.php";
	include "../lock2.php";
	
	if($_POST){
		$name = $_POST["name"];
		
		$sql = "SELECT * FROM area WHERE username = '$name'";
		
		$result = mysqli_query($conn, $sql);
		
		$num = mysqli_num_rows($result);
		
		if(!$num) {
			$sql1 = "INSERT INTO area (name) VALUES ('$name')";
			
			$result = mysqli_query($conn, $sql1);
			
			mysqli_close($conn);
				
			header("Location: ./index.php");
		} else {
			echo "地区已存在";
		}
	}
?>